package com.mxpio.erp.common.plm.entity;

import com.alibaba.druid.sql.dialect.blink.parser.BlinkStatementParser;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.filestorage.entity.MxpioFileInfo;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;

/**
 * 项目列表模板
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "MB_ERP_PLM_PROJECT_INFO_TEMPLATE")
@Schema(description = "项目模板列表")
public class ProjectInfoTemplate extends BaseEntity {
    private static final long serialVersionUID=1L;

    @Id
    @Column(name = "TEMPLATE_CODE")
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "模板编码")
    private String templateCode;

    @Column(name = "PRO_NAME_")
    @Schema(description = "模板名称")
    private String proName; //根据项目名称带入

    @Column(name = "PRO_CODE_")
    @Schema(description = "项目编码")
    private String proCode;

    /**优先级*/
    @Column(name = "PRIORITY_")
    @Schema(description = "优先级")
    @Dict(dicCode = "ERP_PROJECT_INFO_PRIORITY")// 10低级 20中级 30高级
    private String priority;

    /**项目来源*/
    @Column(name = "PRO_SOURCE_")
    @Schema(description = "项目来源")
    @Dict(dicCode = "ERP_PROJECT_INFO_PRO_SOURCE") // 0内部 1外部
    private String proSource;

    /**项目类型*/
    @Column(name = "PRO_TYPE_")
    @Schema(description = "项目类型")
    @Dict(dicCode = "ERP_PROJECT_INFO_PRO_TYPE")
    private String proType;

    /**项目经理*/
    @Column(name = "PRO_LEADER_")
    @Schema(description = "项目经理")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String proLeader;

    /**项目秘书*/
    @Column(name = "PRO_SECRETARY_")
    @Schema(description = "项目秘书")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String proSecretary;

    /**计划开始时间*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "计划开工时间")
    @Column(name = "PLAN_START_TIME_")
    private java.util.Date planStartTime;
    /**计划结束时间*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "计划结束时间")
    @Column(name = "PLAN_END_TIME_")
    private java.util.Date planEndTime;

    /**工期*/
    @Column(name = "DURATION_")
    @Schema(description = "工期")
    private BigDecimal duration;

    /**项目预算*/
    @Column(name = "PRO_BUDGET_")
    @Schema(description = "项目预算")
    private BigDecimal proBudget;

    /**项目范围*/
    @Column(name = "PRO_RANGE_",columnDefinition="TEXT")
    @Schema(description = "项目范围")
    private String proRange;

    /**项目目标*/
    @Column(name = "PRO_TARGET_",columnDefinition="TEXT")
    @Schema(description = "项目目标")
    private String proTarget;

    /**项目章程*/
    @Column(name = "RULES_")
    @Schema(description = "项目章程")
    @Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
    private String rules;

    @Transient
    private List<ProjectDeliverableTemplate> projectDeliverableTemplate;

}
